<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use \common\models\Painting;

/* @var $this yii\web\View */
/* @var $model common\models\Painting */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '作品管理', 'url' => ['index']];
?>
<div class="painting-view">

    <p>
        <?= Html::a('更新作品', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除作品', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'category.category',
            'admin.username',
            'image' => [
                'attribute'=>'image',
                'format' => ['raw'],
                'value' => function($model){
                    return Html::img($model->image, ['height'=>'300px']);
                },
            ],
            // 'thumb',
            'title',
            'describe:ntext',
            'status' => [
                'attribute' => 'status',
                'value' => function ($model) {
                    return isset(Painting::$statusList[$model->status]) ? Painting::$statusList[$model->status] : '未知状态';
                },
            ],
            'show_banner' => [
                'attribute' => 'status',
                'value' => function ($model) {
                    return isset(Painting::$showStatusList[$model->show_banner]) ? Painting::$showStatusList[$model->show_banner] : '未知状态';
                }
            ],
            'created_at:datetime',
            'updated_at:datetime',
        ],
    ]) ?>

</div>
